package sy1_UML.generalization;

abstract class Persion{   //抽象类
    protected String name;
    protected int age;
    public Persion(String name,int age) {  //构造方法
    	this.name=name;
    	this.age=age;
	}
    public abstract void work();  //抽象方法
}

class Student extends Persion{   //学生子类
	public Student(String name, int age) {
		super(name, age);  //调用父类的构造方法
	}
	@Override
	public void work() {
		System.out.println("学生学习.");
	}
}

class Teacher extends Persion{   //教师子类
	public Teacher(String name, int age) {
		super(name, age);  //调用父类的构造方法
	}
	@Override
	public void work() {
		System.out.println("教师上课.");
	}
}

public class Test2 {  //测试类
	public static void main(String[] args) {
		new Teacher("张三", 32).work();
		new Student("李明", 18).work();
	}
}
